import {CreatePunch, GetTravelDetail, VerifyUserTravel} from "../../model/travels"

Page({
    data: {
        html: '',
        isPunch: false
    },
    id: '',
    title: '',
    detailData: {},
    onLoad: function (options) {
        this.id = options.id
        this.title = options.title
        this.getDetail()
    },
    getDetail() {
        GetTravelDetail(this.id).then(res => {
            console.log(res)
            this.detailData = res.data
            wx.setNavigationBarTitle({
                title: this.title
            })
            this.setData({
                html: res.content
            })
        })
        VerifyUserTravel(this.id).then(res => {
            this.setData({
                isPunch: res
            })
        })
    },
    onPunchTap() {
        CreatePunch(this.detailData.id, this.detailData.category).then(res => {
            this.getDetail()
        }).catch(_ => {
            wx.hideLoading()
        })
    }
});
